package com.demo.service;

import com.demo.dto.MessageDTo;
import com.demo.observer.AbstractObserver;
import com.demo.pojo.CommonResponseVo;
import com.demo.utils.MsgFactory;

import java.util.List;

/**
 * @author oyz
 */
public abstract class AbstractMsgService implements MsgService {



    public MsgService chioce(MessageDTo messageDTo) {
        MsgService service = MsgFactory.getService(messageDTo);
        return service;
    }


    // 观察者
    protected final List<AbstractObserver> observers = MsgFactory.OBSERVER_LIST;


    public void notify(MessageDTo messageDTo){
        for (AbstractObserver observer : observers) {
            observer.handle(messageDTo);
        }
    }

    protected CommonResponseVo sendSMS(MessageDTo messageDTo) {

        throw new RuntimeException("error");
    }


    protected CommonResponseVo sendWeChat(MessageDTo messageDTo) {
        throw new RuntimeException("error");
    }


    protected CommonResponseVo sendEMail(MessageDTo messageDTo) {
        throw new RuntimeException("error");
    }


    protected CommonResponseVo sendInternalMsg(MessageDTo messageDTo) {
        throw new RuntimeException("error");
    }

}
